#!/bin/bash
docker pull elasticsearch:2.3.5
if [ ! -d "./es_plugin" ]; then
    mkdir es_plugin
fi 
es_dockerfile=./es_plugin/Dockerfile
if [ -f   "$es_dockerfile" ]; then
    rm $es_dockerfile
fi
touch $es_dockerfile
echo FROM elasticsearch:2.3.5 >> $es_dockerfile
echo RUN /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head >> $es_dockerfile
echo EXPOSE 9200 >> $es_dockerfile
docker build --tag=es_ezio:2.3.5 ./es_plugin
docker run -d -v `pwd`/data:/usr/share/elasticsearch/data -p 9200:9200 --name="es_ezio" es_ezio:2.3.5
rm -rf ./es_plugin
